Quantity: add dunder methods#8
Conversation
lucascolley
left a comment
There was a problem hiding this comment.
I've added some tentative suggestions but I'm not sure that they are correct — @jorenham do my suggestions look closer to what we would want here?
|
I feel like we need to get a type checker going to know what works and doesnt |
Yes, but we then also need |
does it have to be minimal? would a fork of pint (or another module) work? |
yeah, I think so! |
My mental typechecker did not report any errors 👌🏻 |
Exactly; writing annotations without a type-checker is like programming without a compiler or interpreter |
lucascolley
left a comment
There was a problem hiding this comment.
the linked issue also suggests:
__floordiv__,__mod__,__divmod__, shifts, &, ^, |, ...
7623c3f to
5eed30f
Compare
|
type checkers are happy! Any opinions on #5 (comment) @nstarman @neutrinoceros ? |
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
763dc6d to
0f7ec35
Compare
|
alright, let's get this in, we can always revisit other methods as and when need arises. thanks all! |
|
oh I meant to ask if we want to keep rpow |
|
I think so. If we can do |
|
that only makes sense for a unitless quantity, you shouldn't be able to do 2 ** Quantity(2, "m"). I think its reasonable for a library to implement this or not implement it |
|
ah yeah, good point, we should probably remove it then |
not sure if it's a thing, but maybe it makes sense for logarithmic units like decibels? |
|
Agreed. This feels like an API vs implementation issue. If you have access to the runtime, which we do not, then you can distinguish between dimensionful and dimensionless quantities. |
transferred from quantity-dev/quantity-api#6